<!-- 封装的获取商品列表组件 -->
<template>
	<view class="goods_list">
		<view class="goods_item" v-for="item in goods" :key="item.id" @click="navagtor(item.id)">
			<image src="item.img_url"></image>
			<view class="price">
				<text>￥{{item.sell_price}}</text>
				<text>￥{{item.market_price}}</text>
			</view>
			<view class="name">
				{{item.title}}
			</view>
		</view>
	
	</view>
</template>

<script>
	export default{
		props:['goods']	,/*, 谁用“goods_list”这个组件就谁传进来 */
		methods:{
			navagtor(id){
				this.$emit("goodsClick",id)
			}
		}
	}
</script>

<style lang="scss">
	.goods_list{
		padding: 0 15rpx;
		display: flex;
		flex-wrap: wrap;	/* 换行 */
		justify-content: space-between;	/* 有间隙 */
		.goods_item{
			background-color: #fff;
			margin: 10rpx 0;
			border-radius: 16rpx;
			width: 355rpx;
			image{
				width: 80%;
				height: 150px;
				display: block; /* 设为块级元素,就可以使用块级元素的居中方式 */
				margin: 0 auto;
			}
			.price{
					color: #b50e03;
					margin-left: 17rpx;
					font-size: 36rpx;
					text:nth-child(2){
						color: #ccc;
						font-size: 28rpx;
						margin-left: 17rpx;
						text-decoration: line-through;/* 给字符上加上一个删除线 */
					}
			}
			.name{
				margin-left: 17rpx;
				font-size: 25rpx;
				padding-bottom: 15rpx;
				padding-top: 10rpx
				
			}
			
			
		}
	}
</style>
